package com.oceansoft.mobile.common;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.oceansoft.mobile.common.util.CacheBaseService;
import com.oceansoft.mobile.common.util.StringUtils;

/**
 * 系统全局常量
 */
public class Constant {

    public static final Map<String, String> stateMap = new HashMap<String, String>();

    public static final String host5 = "http://172.16.1.101:8080/";
    public static final String hostJxj = "http://police.luopan88.com:8099/";
    public static final String hostSzjjwx = "http://www.trafficeye.com.cn/szjjwx/";

	public static final String local = "http://wjw.szgaj.cn/dszwx/";
// public static final String local = "http://localhost/szgawx/";
//	public static final String local = "http://192.168.1.12:8082/szgawx/";//本地
//	public static final String local = "http://172.168.31.105:8080/szgawx/";


    public static final String REDIRECTURL = local + "oauth/oauth2";

    public static final String host = "http://221.224.13.5:8190/econsole";
//	public static final String host="http://192.168.1.17:8080/econsole";

    public static final String namespace = "http://webservices.szgg.szgt.org/";

    //养犬的外网地址
//	public static final String webServiceUrl = "http://58.210.180.134:7160/szggser/SynInfoPort?wsdl";
    //养犬的私网地址(发布用)
    public static final String webServiceUrl = "http://172.16.3.9:7160/szggser/SynInfoPort?wsdl";


    public static List<Map<String, Object>> appList = new ArrayList<Map<String, Object>>();
    public static Map<String, Map<String, Object>> appMap = new HashMap<String, Map<String, Object>>();
    /**
     * 标准事项名称，以后有标准事项需要进行开发只需在这里添加名称即可
     */
    public static final Map<String, String> caseNameMap = new HashMap<String, String>();

    static {
        stateMap.put("10000",local + "api/standard/gotoPage/standard1"); //所有标准事项
        stateMap.put("10001",local + "api/standard/gotoPage/standard1_1"); //其他特种行业设立备案
        stateMap.put("10002",local + "api/standard/gotoPage/standard1_2"); //娱乐服务场所设立备案、变更告知
        stateMap.put("10003",local + "api/standard/gotoPage/standard1_3"); //大型活动的安全许可
        stateMap.put("10004",local + "api/standard/gotoPage/standard1_4"); //船民证、临时船民证
        stateMap.put("-1", "http://mp.weixin.qq.com/s?__biz=MzA4MzMxODkzNQ==&mid=2659775279&idx=3&sn=09a1ddc3e47860cceea6a4c8c678a305#rd");
        //stateMap.put("-1", "http://weixin.qq.com/r/QUxqch3EtEDLrVkR9xlT");//苏州微警务公众号关注页面
        stateMap.put("-2", "http://mp.weixin.qq.com/s/vT_eyXZ-ZSq4z0bYxi1kqw");
        stateMap.put("0", local + "micro/police");
        stateMap.put("3", local + "api/sgcltxz/sgcltxz2");//施工车辆通行证
        stateMap.put("4", local + "api/consult/gotoPage/lyzx");
        stateMap.put("5", local + "api/consult/gotoPage/my_consult");
        stateMap.put("6", local + "api/hclstxz/hclstxz");//货车临时通行证
        stateMap.put("7", local + "api/callPolice/gotoPageWithUser/unlock_help");//开锁求助
        stateMap.put("8", local + "micro/gotoPageWithUser/dlyc");//堵路移车
        stateMap.put("9", local + "micro/gotoWithUser/sxsba");//利用道路、公共广场等设置停车泊位的审批
        stateMap.put("10", local + "micro/gotoWithUser/sxsbe1");//影响交通安全的道路挖掘、占用或跨越、穿越道路架设、埋设管线设施许可
        stateMap.put("11", local + "api/netApprove/gotoPageWithUser/jsjxxwl");//联保备案
        stateMap.put("12", local + "api/applyMatters/gotopageWithUser/sxsbb1");//家属网上预约会见在押人员
        stateMap.put("13", local + "api/applyMatters/gotopageWithUser/sxsbc");//家属申请网上视频会见在押人员
        stateMap.put("14", local + "api/applyMatters/gotopageWithUser/sxsbd");//网上预约参观监管场所
        stateMap.put("15", local + "api/applyMatters/gotopageWithUser/sqmphm1");//申请门牌号码
        stateMap.put("16", local + "api/applyMatters/gotopageWithUser/xzfy1");//行政复议申请
        stateMap.put("17", local + "api/applyMatters/gotopageWithUser/lawyermeet");//律师网上预约会见在押人员
//        stateMap.put("18", local + "api/traffic/gotoTrafficByUser/indexzscg");//掌上车管
//        stateMap.put("19", local + "api/traffic/gotoTrafficByUser/indexwfcl");//交通违法处理
        stateMap.put("18", hostJxj + "login3.html");//掌上车管
        stateMap.put("19", hostJxj + "login2.html");//交通违法处理
        stateMap.put("20", hostJxj + "indexsgkc.html");//事故快撤
        stateMap.put("21", hostSzjjwx + "index2.html?adcode=320500");//实时路况
        stateMap.put("22", hostSzjjwx + "index3.html?adcode=320500");//路况简图
//        stateMap.put("23", local + "api/query/1.html");//重名查询
        stateMap.put("23", local + "micro/getPageWithToken/cmcx");//重名查询
        stateMap.put("24", local + "api/query/9.html");//身份证办理进度查询
        stateMap.put("25", local + "api/query/6.html");//居住证办理点查询
        stateMap.put("26", local + "api/query/7.html");//居住证办理进度查询
        stateMap.put("27", local + "api/query/2.html");//案件查询
        stateMap.put("28", local + "api/query/8.html");//办件进度查询
        //出行指南
        // stateMap.put("29",  "http://mp.weixin.qq.com/s?__biz=MzA4MzMxODkzNQ==&mid=2659775893&idx=2&sn=370a66e862150c5e0088f6382ae95384&scene=1&srcid=0823KFiTWjdUlTJsYcYpiIwT&from=singlemessage&isappinstalled=0#wechat_redirect");
        stateMap.put("29", "http://mp.weixin.qq.com/s/pKTwJPyMuJcsNi5NB1G2UA");
        stateMap.put("30", local + "api/query/10.html");//户口办理进度查询
        stateMap.put("31", local + "api/applyMatters/gotopageWithUser/hkysl");//户口预受理
        stateMap.put("32", local + "api/applyMatters/gotopageWithUser/hzyy");//户口预约
        stateMap.put("62", local + "api/applyMatters/gotopageWithUser/hkzxbl");//户口在线办理

        stateMap.put("33", local + "api/owner_dog/exec");   //养犬管理主页面
//        stateMap.put("34", local + "api/owner_dog/progress");   //养犬管理申报解读
        stateMap.put("35", local + "static/weixin/html/zayq/yqgltl.html");   //养犬管理管理条例
        stateMap.put("36", local + "static/weixin/html/zayq/jypz.html");   //养犬管理品种说明
        stateMap.put("37", local + "static/weixin/html/zayq/yqglbzsyt.html");   //养犬管理犬证办理流程
        stateMap.put("38", local + "api/owner_dog/zxbl");   //养犬管理在线办理
        stateMap.put("39", local + "api/owner_dog/progress");   //养犬管理申办查询
        stateMap.put("40", local + "api/owner_dog/jjyw");   //养犬管理就近业务
        stateMap.put("41", local + "api/owner_dog/zxdt_page");   //养犬管理最新动态

        stateMap.put("45", "http://crjwx.szgaj.cn");   //出入境微信首页
        stateMap.put("46", "http://crjwx.szgaj.cn/BZXZ");   //办证须知
        stateMap.put("47", "http://crjwx.szgaj.cn/YWCX/BZWD");   //网点查询
        stateMap.put("48", "http://crjwx.szgaj.cn/GAZSQ");   //签注办理
        stateMap.put("49", "http://crjwx.szgaj.cn/BZYY");//预约申请

        stateMap.put("51", local + "static/weixin/html/police_map.html");   //警务地图
        stateMap.put("52", local + "api/query/11.html");//外来人口积分查询
        stateMap.put("53", local + "api/query/12.html");//交通违法查询
        stateMap.put("54", "http://pass.szcw.cn");//货车长期通行证

        stateMap.put("55", local + "api/chemical/gotopageWithUser/yzdhxp2");//第三类易制毒化学品运输备案
        stateMap.put("56", local + "api/chemical/gotopageWithUser/yzdhxp4");//第二、三类易制毒化学品购买备案
        stateMap.put("57", local + "api/chemical/gotopageWithUser/yzdhxp5");//第二类易制毒化学品运输许可证核发
        stateMap.put("58", local + "api/chemical/gotopageWithUser/jzzbl2");//居住证办理
//        stateMap.put("55", local + "api/chemical/gotopageWithUser/yzdhxp1");//易制毒化学品

        stateMap.put("60", local + "api/lawyerRecord/gotopageWithUser/addRecord");//新增律师备案
        stateMap.put("61", local + "api/lawyerRecord/gotopageWithUser/queryRecord");//查询律师备案
        //新增户口在线办理：62
        stateMap.put("91", "http://www.trafficeye.com.cn/szjjwx/index4.html?adcode=320500"); //交通管制
        stateMap.put("92", "http://www.trafficeye.com.cn/szjjwx/index5.html?adcode=320500"); //交通指数
        stateMap.put("100", "http://www.zfgs.jsga.gov.cn:9080/wx_zfgspt/hmpage.htm"); //咨询投诉
        stateMap.put("101", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc2a62dcb8a7c808e&redirect_uri=http://www.jsems.com.cn/emspid/index.php&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"); //身份证寄递信息录入
    }

    static {
//        caseNameMap.put("1", "大型活动的安全许可");
        caseNameMap.put("2", "典当业特种行业许可证核发");
        caseNameMap.put("3", "旅馆业特种行业许可证核发");
        caseNameMap.put("4", "公章刻制业特种行业许可证核发");
        caseNameMap.put("5", "公章（法人印鉴）刻制备案");
        caseNameMap.put("6", "生产性废旧金属收购业列入名录");
        caseNameMap.put("7", "开锁业列入名录");
        caseNameMap.put("8", "民用爆炸物品购买许可");
        caseNameMap.put("9", "生产管制器具单位备案");
        caseNameMap.put("10", "射钉弹备案");
        caseNameMap.put("11", "爆破作业单位许可证核发");
        caseNameMap.put("12", "船民证");
        caseNameMap.put("13", "临时船民证发放");
        caseNameMap.put("14", "船舶户牌、船舶户口簿及登记项目变更");
        caseNameMap.put("15", "本人人口信息证明");
//        caseNameMap.put("16", "出具户籍信息证明");
        caseNameMap.put("17", "出具弃婴（儿童）报案证明预受理");
        caseNameMap.put("18", "出具非正常死亡证明");
//        caseNameMap.put("19", "出具临时身份证明");
        caseNameMap.put("20", "出具违法犯罪证明预受理");
        caseNameMap.put("21", "公共场所（娱乐场所、服务场所）变更名称、地址、法定代表人或者经营负责人、经营范围以及其他重要事项的备案");
        caseNameMap.put("22", "娱乐场所备案");
//        caseNameMap.put("23", "犬证犬牌核发");
        caseNameMap.put("24", "大型群众性活动（1000-5000人）");
        caseNameMap.put("25", "5000人以上大型活动的安全许可");
        caseNameMap.put("26", "寄卖业备案");
        caseNameMap.put("27", "旧车辆交易备案");
        caseNameMap.put("28", "旧笔记本电脑交易业备案");
        caseNameMap.put("29", "金银首饰加工、置换业备案");
        caseNameMap.put("30", "报废机动车回收拆解业备案");
        caseNameMap.put("31", "汽车租赁业备案");
        caseNameMap.put("32", "印刷业备案");
        caseNameMap.put("33", "第三类易制毒化学品运输备案");
        caseNameMap.put("34", "第二、三类易制毒化学品购买备案");
        caseNameMap.put("35", "第二类易制毒化学品运输许可证核发");
//        caseNameMap.put("36", "居住证办理");

    }

    /**
     * 角色ID
     */
    public static final long ROLE_SUPER_ADMIN = 0;//平台管理员
    public static final long ROLE_MERCHANT_ADMIN = 1;//商家管理员  可以增删改查
    public static final long ROLE_MERCHANT_CUSTOMSERVICE = 2;//商家客服人员  只能浏览

    /**
     * 首页级别
     */
    public static final int TEMPLATE_LEVEL_iNDEX_PAGE = 1;

    /**
     * 栏目级别
     */
    public static final int TEMPLATE_LEVEL_CHANNEL_PAGE = 2;

    /**
     * 详细产品级别
     */
    public static final int TEMPLATE_LEVEL_DETAIL_PAGE = 3;
    /**
     * 数据库新增成功
     */
    public static final int DB_SAVE_ONE_SUCC = 1;
    /**
     * 操作数据库唯一记录成功
     */
    public static final int DB_OPER_ONE_SUCC = 1;


    public static String sep = File.separator;

    /**
     * 商家图片目录
     */
    public static String PIC_BASE_PATH = sep + "usr" + sep + "share" + sep + "szgawx" + sep + "static";

    /**
     * 文章图片目录
     */
    public static String PIC_ART_PATH = "articlepic";

    /**
     * 乐在苏州户外活动的线路图片
     */
    public static String PIC_OUTDOOR_PATH = "activity-outdoor";
    /**
     * 乐在苏州商家的产品图片
     */
    public static String PIC_MERCHANT_PATH = "activity-mer";
    /**
     * 商家业务附件存储路径前缀
     */
//    public static final String BIZ_FILE_PATH_PREFIX = "saestor://";
    public static final String BIZ_FILE_PATH_PREFIX = "biz";
    /**
     * 商家状态--全部
     */
    public static final int MERCHANT_STATUS_ALL = -1;
    /**
     * 商家状态--可用
     */
    public static final int MERCHANT_STATUS_VALIDATE = 1;
    /**
     * 商家状态--不可用
     */
    public static final int MERCHANT_STATUS_INVALIDATE = 0;
    /**
     * 无LOGO类型栏目
     */
    public static final int CHANNEL_TYPE_NO_LOGO = 0;
    /**
     * 有LOGO类型栏目
     */
    public static final int CHANNEL_TYPE_HAS_LOGO = 1;
    /**
     * 全部类型栏目
     */
    public static int CHANNEL_TYPE_ALL = -1;
    /**
     * 全局分页值
     */
    public static int PAGE_SIZE = 11;

    /**
     * 角色拥有的权限
     */
    public static String AUTHORITY = "AUTHORITY";

    /**
     * 平台管理员用户SESSION标识位
     */
    public static String GLOBAL_ADMIN_SESSION = "GLOBAL_ADMIN_SESSION";
    /**
     * 商家管理员SESSION标识位
     */
    public static String GLOBAL_SESSION = "GLOBAL_SESSION";
    /**
     * 商家客服SESSION标识位
     */
    public static String GLOBAL_SERVICE = "GLOBAL_SERVICE";

    /**
     * 网站用户SESSION标识位
     */
    public static String GLOBAL_USER = "GLOBAL_USER";

    /**
     * 登录用户是否为管理员标识
     */
    public static int ROLE_ADMINISTRATOR = 0;

    /**
     * 触发类型 0 - 无
     */
    public static String CLICK_TYPE_NONE = "无";
    /**
     * 触发类型 1 - 点击触发
     */
    public static String CLICK_TYPE_CLICK = "click";
    /**
     * 触发类型 2 - 网页形式
     */
    public static String CLICK_TYPE_VIEW = "view";

    public static String THEMEID = "themeId";
    public static String MERCHANTID = "mer_Id";
    public static String OPENID = "openid";

    public static int QUERY_RANGE_ALL = -1;
    public static int QUERY_RANGE_1 = 1;
    public static int QUERY_RANGE_0 = 0;
    /**
     * 重新绑定手机
     */
    public static final int SMS_BIZ_REBIND_MOBILE = 1;
    /**
     * 注册新用户
     */
    public static final int SMS_BIZ_REGISTER = 2;
    /**
     * 重置用户密码
     */
    public static final int SMS_BIZ_RESET_PASSWORD = 3;
    /**
     * 普通用户SESSION标识位
     */
    public static String SESSION_USER = "session_user";
    /**
     * 失物招领list
     */
    public static String SESSION_FINDGOODS = "session_findgoods";

    /**
     * 施工车辆申报信息
     */
    public static String SESSION_SGCLTXZSQ = "session_sgcltxzsq";
    /**
     * 施工车辆附件信息
     */
    public static String SESSION_SGCL_FJ = "session_sgcl_fj";
    /**
     * 施工车辆通用申报信息
     */
    public static String SESSION_SGCL_TY = "session_sgcl_ty";

    /**
     * 货车申报信息
     */
    public static String SESSION_HCLSTXZSQ = "session_hclstxzsq";
    /**
     * 货车附件信息
     */
    public static String SESSION_HCLS_FJ = "session_hcls_fj";
    /**
     * 货车通用申报信息
     */
    public static String SESSION_HCLS_TY = "session_hcls_ty";
    /**
     * 微信文件上传路径
     */
    public static final String SZGAWX_UPLOAD_PATH = "/usr/share/szgawx/static/upload/";
    /**
     * 律师预约--告知办案单位
     */
    public static String SESSION_LAWYER_JudgePer = "session_lawyer_judgeper";
    /**
     * 律师预约--网上预约
     */
    public static String SESSION_LAWYER_FJ = "session_lawyer_fj";
    /**
     * 律师备案--律师信息
     */
    public static String SESSION_LAWYER = "session_lawyer";
    /**
     * Freemarker模版路径
     */
    public static final String PATH_FTL_TEMPLATE = sep + "WEB-INF" + sep + "Template" + sep;
    public static final String FILE_COMM = "导出记录";


    public static boolean checkIssz(String source) {
        return checkAttribute(source, "issz");
    }

    public static boolean checkIswx(String source) {
        return checkAttribute(source, "iswx");
    }

    public static boolean checkIstoken(String source) {
        return checkAttribute(source, "istoken");
    }

    public static final String UC_USER = "pasc_login_status";

    public static final String UC_URL = "http://221.226.3.55:8080/sgat_qjd/auth/loginToUrl.do?appMark=szgawjw&gotoUrl=";
    //redis标识，苏州公安微警务toekn（PC用）
    public static final String SZGA_TOKEN = "uc:szga_token";

    private static boolean checkAttribute(String source, String key) {
        if (StringUtils.isEmpty(source)) {
            return true;
        }
        if (StringUtils.isNotBlank(source)) {
            /*for (Map<String,Object> m : appList) {
				if(source.equals(m.get("sourceid")))
				{
					String v = (String)m.get(key);
					if("1".equals(v))
					{
						return true;
					}
					else
					{
						return false;
					}
				}
			}*/

//			Map<String,Object> m = appMap.get(source);

            Map<String, Map<String, Object>> cacheAppMap = ((Map<String, Map<String, Object>>) (CacheBaseService.getInstance().getObject("appMap")));
            if (null == cacheAppMap) {
                cacheAppMap = appMap;
            }
            Map<String, Object> m = cacheAppMap.get(source);
            if (null != m) {
                String v = (String) m.get(key);
                if ("1".equals(v)) {
                    return true;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
}


